package mshop.com.schild_kotlin.mvp.presenter

import android.content.Context
import mshop.com.schild_kotlin.base.applySchedulers
import mshop.com.schild_kotlin.entitys.HotBean
import mshop.com.schild_kotlin.mvp.base.BaseContract
import mshop.com.schild_kotlin.mvp.model.HotModel
import mshop.com.schild_kotlin.network.MyObserver

/**
 * Created by mayi on 2018/5/28.
 * @Autor CaiWF
 * @Email 401885064@qq.com
 * @TODO
 */
class HotPresenter(var strategy: String, var mContext: Context?, var view: BaseContract.View<HotBean>) : BaseContract.Presenter {
    val mModel: HotModel by lazy {
        HotModel()
    }


    override fun requestData() {
        mContext?.let {
            mModel.loadData(it, strategy).applySchedulers().subscribe(object : MyObserver<HotBean>(it) {
                override fun onNext(t: HotBean) {
                    view.setData(t)
                }
            })
        }
    }

    override fun start() {
        requestData()
    }

}